package com.bjshiwei.zhengu.utils;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 作者：Administrator on 2016/11/10 0010 17:46
 * 邮箱：sanjins@126.com
 */


public class IndividualDao {
    private SQLiteOpenHelper mUSqLiteOpenHelper;
    private SQLiteDatabase mDb;
    public IndividualDao(Context context){
        mUSqLiteOpenHelper = DatabaseHelper.getHelper(context);
        mDb = mUSqLiteOpenHelper.getReadableDatabase();
    }
    
    public  boolean insert(String table, ContentValues values){
        long insert = mDb.insert(table, null, values);
        if(insert>0) {
            return true;
        }
        return false;
    }

    public Cursor findAll(String table, String[] columns, String selection, String[] selectionArgs){
        Cursor cursor = mDb.query(table, columns, selection, selectionArgs, null, null, null, null);
        return cursor;
    }

    public boolean del(String table, String whereClause, String[] whereArgs){
        int delete = mDb.delete(table, whereClause, whereArgs);
        if(delete>0) {
            return true;
        }
        return false;
    }
}
